<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2014 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace Wx\Controller;
use Common\Controller\HomebaseController;
require_once './plugins/WxPay/WxPayLib.php';

class WxPayController extends HomebaseController {


    // native 支付方式，扫码支付二维码
    public function send_native_pay_request($product_desc, $attach, $order_no, $total_fee, $product_id)
    {
        \WxPayCall::SendPayRequest($product_desc, $attach, $order_no, $total_fee, $product_id);
    }

    // h5 支付方式，移动端支付
    public function send_h5_pay_request($product_desc, $attach, $order_no, $total_fee, $redirect_url)
    {
        $pay_url = \WxPayCall::sendH5PayRequest($product_desc, $attach, $order_no, $total_fee, $redirect_url);
        return $pay_url;
    }

    // jsapi 支付（微信内），获取参数
    public function getJsapiPayParameters($product_desc, $attach, $order_no, $total_fee, $product_id, $open_id)
    {
        $parameters = \WxPayCall::getJsapiPayParameters($product_desc, $attach, $order_no, $total_fee, $product_id, $open_id);
        return $parameters;
    }

    // jsapi 支付（微信内），获取参数
    public function getMiniPayParameters($product_desc, $attach, $order_no, $total_fee, $product_id, $open_id)
    {
        $parameters = \WxPayCall::getMiniPayParameters($product_desc, $attach, $order_no, $total_fee, $product_id, $open_id);
        return $parameters;
    }

    // 微信付款到用户零钱
    public function refundOrder($partner_trade_no, $amount, $desc, $open_id)
    {
        $result = \WxPayCall::refundOrder($partner_trade_no, $amount, $desc, $open_id);
        return $result;
    }

    // 接受微信支付结果通知
    public function notify()
    {
        \PayNotifyCallBack::notify();
    }
}
